<template>
  <view style="width: 100%;height: 100%;display: flex;flex-direction: column">
    <Input v-model="base64Data" type="textarea" :rows="4" placeholder="请输入base64数据" />

    <div style="width:100%;margin-top: 16px;position: relative">
      <Input type="textarea" :rows="4" v-model="text">
      </Input>
      <div style="position: absolute;right: 8px;bottom: 4px;cursor: pointer" class="lz-color-primary" @click="copyData">
        <Icon type="md-copy" />
        复制
      </div>
    </div>
  </view>
</template>

<script setup>
import {Base64} from 'js-base64'
import {computed, ref} from 'vue'
import {Message} from 'view-ui-plus'
const base64Data=ref('')
const text=computed(()=>{
  try {
    return Base64.decode(base64Data.value)
  }catch (e){
    return ''
  }
})

async function copyData() {
  const rs=await navigator.clipboard.writeText(text.value)
  Message.success({
    content:`复制成功`
  })
}

</script>

<style scoped>

</style>
